package examples;

import com4j.Variant;
import msword.*;

/**
 * @author yuan zhen chao
 * @date 2019/11/26
 */
public class WordSaveAsPdf {
    public static void main(String[] args) {
        _Application app = ClassFactory.createApplication();
        app.visible(false);
        String inPath = "D:\\tmp\\8000180830\\6_7294723.doc";
        _Document doc = app.documents().open(inPath, false, true,
                false, Variant.getMissing(), Variant.getMissing(),
                Variant.getMissing(), Variant.getMissing(),
                Variant.getMissing(), WdOpenFormat.wdOpenFormatAuto, MsoEncoding.msoEncodingWestern,
                Variant.getMissing(), Variant.getMissing(), WdDocumentDirection.wdLeftToRight, Variant.getMissing(), Variant.getMissing());
        String outpath = "D:\\tmp\\8000180830\\6_7294723.pdf";
        doc.saveAs2(outpath, WdSaveFormat.wdFormatPDF, Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(),
                Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(),
                Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing());

        doc.close(false, false, false);
        app.quit(false, false, false);
    }
}
